package com.itheima.mapper;

import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
//    @Select("select count(*) from tlias.emp")
//    public Long count();
//    @Select("select * from tlias.emp limit #{start},#{pageSize}")
//    public List<Emp> pageList(@Param("start") Integer start,@Param("pageSize") Integer pageSize);
//    @Select("select * from tlias.emp")
    public List<Emp> list(@Param("name") String name,@Param("gender") Short gender,@Param("begin") LocalDate begin,@Param("end") LocalDate end);

    void deleteById(@Param("ids") List<Integer> ids);

    @Insert("insert into tlias.emp(tlias.emp.username, tlias.emp.name, tlias.emp.gender, tlias.emp.image, tlias.emp.job, tlias.emp.entrydate, tlias.emp.dept_id, tlias.emp.create_time, tlias.emp.update_time) " +
            "values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime}) ")
    void inster(Emp emp);

    @Select("select * from tlias.emp where id=#{id}")
    List<Emp> selectList(Integer id);

    void updateList(Emp emp);
    @Select("select * from tlias.emp where username=#{username} and password=#{password}")
    Emp selectNameAndPassword(Emp emp);

    @Delete("delete from tlias.emp where tlias.emp.dept_id=#{deptId}")
    void deleteByDeptId(Integer deptId);
}